1. Field of the Invention
This invention relates generally to optimizing compilers for development of computer programs for use on a computer, and more particularly to value numbering.
2. Description of the Related Art
A problem addressed by the optimizing compiler prior art is equivalence of expressions. Value numbering is a conventional technique for identifying expressions of equivalent values. A value number in the prior art is a symbolic execution of a basic block of code, in which all variables entering that basic block of code (straight line code) are given distinct symbolic values or value numbers. The technique of value numbering is used for common subexpression elimination within a basic block, where if a symbolic value is computed twice within the same basic block, then it may be eliminated the second time. However, use of the prior art value number techniques are limited to a single basic block or an extended basic block (two adjacent basic blocks). The prior art techniques do not provide optimizations such as common subexpression elimination or redundancy removal beyond basic blocks and extended basic blocks to an entire program consisting of multiple extended basic blocks.
Value numbering optimization may be understood by reference to the optimizing compiler art. FIG. 1 illustrates a procedure for translating a program 10 to create an executable binary object program 12. A lexical/syntax analysis 14 is conducted to transform source program 10 to a first intermediate language program 16. First intermediate language program 16 is then processed by an optimization routine 18 to create a second intermediate language program 20, which is then directly interpreted by the code generation routine 22 to create object program 12.
Optimization routine 18 is illustrated in FIG. 2 as it is understood in the art. Optimization processing is achieved by first performing a control flow analysis in routine 24 of first intermediate language 16. Control flow analysis routine 24 provides the control flow data 26, which are then passed to a data-flow analysis routine 28 wherein first intermediate language program 16 is analyzed for data flow. Conventional value numbering may be regarded as part of this data flow analysis. Data-flow analysis routine 28 produces the data-flow data 30. Finally, a program transformation procedure 32 accepts control flow data 26, data-flow data 30, and first intermediate language program 16 to produce second intermediate language program 20. Optimization routine 18 may use value numbering to enable the program transformation procedure 32 to perform various optimizations such as induction variable analysis, dependence analysis, and loop fusion.
Many methods for value numbering are known in the art. For instance, in Rosen et al. (B. Rosen, M. Wegman, and K. Zadeck, "Global Value Numbers and Redundant Computations", Fifteenth ACM Principles of Programming Languages Symposium, 12-27, January 1988, San Diego, Calif.), a program is translated into Static Single Assignment Form (SSA). See Cytron et al. (R. Cytron and J. Ferrante, "An Efficient Method for Computing Static Single Assignment Form", Sixteenth Annual ACM Symposium on Principles of Programming Languages Symposium, 25-35, January 1989), and then value numbering is performed locally in basic blocks.
Thus, practitioners in the art generally employ value numbers only within basic blocks or extended basic blocks to perform various optimizations, and there is an accordingly clearly-felt need in the art for a global value numbering that may be performed globally across an entire computer program.